from rest_framework.generics import ListAPIView, RetrieveAPIView
from .serializers import DissDetailSerializer, DisscommentSerializer, FristPageSerializer
from .models import Diss, Comment


# Create your views here.


# GET http://{{host}}/diss/{id=1}
class DissFristPageView(ListAPIView):
    """吐槽首页"""
    serializer_class = FristPageSerializer
    pagination_class = None
    queryset = Diss.objects.all().order_by("-create_time")


# TODO 进行表与评论之间的关联
class DissDetailView(RetrieveAPIView):
    serializer_class = DissDetailSerializer
    """吐槽文章详情"""
    queryset = Diss.objects.all()
    # queryset = Diss.objects.all().order_by("-diss_comment_like_count")
    pagination_class = None


class DissCommentView(ListAPIView):
    serializer_class = DisscommentSerializer
    """吐槽评论详情"""
    queryset = Comment.objects.all()


